import Vue from "vue";
import VueRouter from "vue-router";
import routes from "./routes";

Vue.use(VueRouter);

const router = new VueRouter({
  routes,
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  if (process.env.NODE_ENV === "development")
    originalPush.call(this, location).catch((err) => err);
};

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || "CRM系统";
  next();
});

export default router;
